#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int a, b, c;
	a = b = c = 0;
	string s;
	cin >> s;

	int index = s.find(":=");
	while (index != -1) {
		if (s[index - 1] == 'a') {
			string val = s.substr(index + 2, s.find(";", index) - index - 2);
			if ('0' <= val[0] && val[0] <= '9') {
				a = stoll(val);
			} else {
				if (val[0] == 'a')
					a = a;
				else if (val[0] == 'b')
					a = b;
				else
					a = c;
			}
		} else if (s[index - 1] == 'b') {
			string val = s.substr(index + 2, s.find(";", index) - index - 2);
			if ('0' <= val[0] && val[0] <= '9') {
				b = stoll(val);
			} else {
				if (val[0] == 'a')
					b = a;
				else if (val[0] == 'b')
					b = b;
				else
					b = c;
			}
		} else {
			string val = s.substr(index + 2, s.find(";", index) - index - 2);
			if ('0' <= val[0] && val[0] <= '9') {
				c = stoll(val);
			} else {
				if (val[0] == 'a')
					c = a;
				else if (val[0] == 'b')
					c = b;
				else
					c = c;
			}
		}
//		cout << a << " " << b << " " << c << endl;
		index = s.find(":=", index + 1);
	}
	cout << a << " " << b << " " << c;
	return 0;
}
